﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Blog.TemplateEngine.Nodes
{
    class FilterNode : INode
    {
        INode mFilteredNode;
        string mParameter;
        IFilter mFilter;

        public FilterNode(INode filteredNode, IFilter filter)
            : this(filteredNode, filter, null)
        {
        }

        public FilterNode(INode filteredNode, IFilter filter, string parameter)
        {
            mFilteredNode = filteredNode;
            mFilter = filter;
            mParameter = parameter;
        }

        protected string Render(Context context)
        {
            return mFilter.Filter(mFilteredNode.Render(context), mParameter);
        }

        string INode.Render(Context context)
        {
            return Render(context);
        }
    }
}
